<?php

// Created by Khanh Nam
class CanLockRecord extends CActiveRecord{
    public $submitButtonText;
    public function getSubmitButtonText(){
      
        if($this->isNewRecord){
            return  "Create";
        }else{
            if($this->lockby!=NULL && $this->lockby!=Yii::app()->user->name){      
                return "Lock by ".Users::getUserNameByEmail($this->lockby);
            }else{
                return "Save";
            }
        }
       
    }
    public function beforeSave() {
      
        if($this->lockby!=NULL && $this->lockby!=Yii::app()->user->name){      
            
            return false;
        }
        return parent::beforeSave();
    }
}
?>
